/**
 * 预答辩-接口文件
 */
import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
const baseUrl = "/api/compulsoryservice";

// 我的预答辩表格查询
export const applyTableList = `${baseUrl}/thesisPreDefenseApplyInfoT/query`;

// 预答辩申请-新增、修改
export function preDefenseApply(data) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/apply`,
      method: 'post',
      data
  })
}

// 预答辩申请-详情
export function applyDetail(data) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/getDetail?id=${data}`,
      method: 'get'
  })
}

//预答辩-撤回接口
export function auditReject(data) {
  return fetch({
    url: `${baseUrl}/thesisPreDefenseApplyInfoT/batchReject`,
    method: 'put',
    data
  })
}

// 预答辩申请-列表查询
export function applyList(data) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/query`,
      method: 'post',
      data
  })
}

// 预答辩申请-录入意见
export function applyInputOpinion(data) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/inputOpinion`,
      method: 'post',
      data
  })
}

// 预答辩申请-获取用户信息
export function applyGetStu(data) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/getStu`,
      method: 'get'
  })
}

// 预答辩申请-导出申请表
export function applyExportDoc(data,title) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/exportDoc?id=${data}`,
      method: 'get'
  }).then(res => {
    UTILS.downloadFile(
        res,
        title,
        'application/msword;charset=utf-8'
    );
  });
}

// 预答辩成绩录入及查询-成绩录入
export function lookInsertScore(data) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/insertScore`,
      method: 'post',
      data
  })
}

// 预答辩成绩录入及查询-导出
export function lookExportTable(data) {
  return fetch({
      url: `${baseUrl}/thesisPreDefenseApplyInfoT/exportTable`,
      method: 'post',
      responseType: "blob",
      data,
      timeout: 0
  }).then(res => {
    UTILS.downloadFile(
      res,
      "预答辩结果.xls",
      "application/vnd.ms-excel;charset=utf-8"
    );
  });
}
